package com.uraurora.crescent.tuple;

import com.sun.istack.internal.NotNull;
import com.uraurora.crescent.util.SeiIterables;

/**
 * 包含两个元素的元组类
 * @author ：Sei
 * @param <T1>
 * @param <T2>
 */
public class Tuple2<T1, T2> extends AbstractTuple implements ITuple {

    private final static int SIZE = 2;

    private Tuple2(Object[] values){
        super(values);
    }

    public static <T1, T2> Tuple2<T1, T2> of(T1 t1, T2 t2){
        Object[] objects = {t1, t2};
        return new Tuple2<>(objects);
    }

    static <T1, T2> Tuple2<T1, T2> of(@NotNull Iterable<?> iterable){
        Object[] obj = SeiIterables.toArray(iterable, SIZE);
        return new Tuple2<>(obj);
    }

}
